﻿@using com.hyrentals.webcommon.extensions
@using com.hyrentals.webportal.Config
@using com.hyrentals.data

@model com.hyrentals.data.RV
@{
    Html.AddStyle("css/rv");
    Html.AddTailScript("js/rv-overview");

    string calendarUrl = string.Format("/rv/{0}/edit/calendar", Model.Id);
    string pricingUrl = string.Format("/rv/{0}/edit/pricing", Model.Id);
    string overviewUrl = string.Format("/rv/{0}/edit/overview", Model.Id);
    string automotiveUrl = string.Format("/rv/{0}/edit/automotive", Model.Id);
    string interiorUrl = string.Format("/rv/{0}/edit/interior", Model.Id);
    string photosUrl = string.Format("/rv/{0}/edit/photos", Model.Id);
    string addressUrl = string.Format("/rv/{0}/edit/address", Model.Id);
}

<div class="layout-primary">
    <div class="layout-primary-left">
        <ul class="manage-rv-nav">
            <li><a href="@calendarUrl">Calendar</a></li>
            <li><a href="@pricingUrl">Pricing</a></li>
            <li><a class="active" href="@overviewUrl">Overview</a></li>
            <li><a href="@automotiveUrl">RV Details</a></li>
            <li><a href="@photosUrl">Photos</a></li>
            <li><a href="@addressUrl">Address</a></li>
        </ul>
    </div>
    <div class="layout-primary-middle">
        <form id="J_Overview" class="form-s1 form-overview" action="" method="post">
            <div class="valid-simple">
            <input type="hidden" value="@Model.Id" name="id"/>
                <div class="row clearfix">
                    <label for="title" class="label">Title</label>
                    <div class="right">
                        <p class="clearfix"><input id="title" class="input-text large-input" type="text" name="title"  value="@Model.Title" data-msgbox="#msg_title" /></p>
                        <p id="msg_title" class="tip"></p>
                    </div>
                </div>
                <div class="row clearfix">
                    <label for="summary" class="label">Summary</label>
                    <div class="right">
                        <textarea id="summary" class="input-textarea large-input" rows="6" style="width: 300px;" name="summary" data-msgbox="#msg_summary">@Model.Summary</textarea>
                        <p id="msg_summary" class="tip"></p>
                    </div>
                </div>
                <div class="row clearfix">
                    <label for="type" class="label">RV Type</label>
                    <select id="type" class="select" name="type" data-msgbox="#msg_type">
                    @{
                        foreach (RVTypeEnum type in Enum.GetValues(typeof(RVTypeEnum)))
                        {
                            byte index = (byte)type;
                            string name = NameMapping.RVTypeEnumNameArray[index];
                            if (type != RVTypeEnum.Other)
                            {
                                if (type == Model.RVType)
                                {
                                    <option value="@index" selected="selected">@name</option>
                                }
                                else
                                {
                                    <option value="@index">@name</option>
                                }
                            }
                        }

                        byte RVTypeOtherIndex = (byte)RVTypeEnum.Other;
                        string RVTypeOtherName = NameMapping.RVTypeEnumNameArray[RVTypeOtherIndex];
                        if (RVTypeEnum.Other == Model.RVType)
                        {
                            <option value="@RVTypeOtherIndex" selected="selected">@RVTypeOtherName</option>
                        }
                        else
                        {
                            <option value="@RVTypeOtherIndex">@RVTypeOtherName</option>
                        }
                    }
                    </select>
                    <span id="msg_type" style="display: none;"></span>
                </div>
                <div class="row clearfix">
                    <label for="model_style" class="label">Model & Style</label>
                    <input id="model_style" class="input-text" type="text" name="modelstyle" value="@Model.ModelStyle" data-msgbox="#msg_model_style" />
                    <span id="msg_model_style" style="display: none;"></span>
                </div>
                <div class="row clearfix">
                    <label for="made_year" class="label">Year</label>
                    <select id="made_year" class="select" name="madeYear" data-msgbox="#msg_made_year">
                    @{
                        DateTime now = DateTime.UtcNow;
                        int nowYear = now.Year;
                        for (int i = nowYear, endYear = nowYear - 50; i > endYear; --i)
                        {
                            if (i == Model.MadeYear.Year)
                            {
                                <option value="@i" selected="selected">@i</option>
                            }
                            else
                            {
                                <option value="@i">@i</option>
                            }
                        }
                    }
                    </select>
                    <span id="msg_made_year" style="display: none;"></span>
                </div>
                <div class="row clearfix">
                <label for="made_by" class="label">Made by</label>
                    <select id="made_by" class="select" name="madeBy" data-msgbox="#msg_made_by">
                    @{
                        foreach (RVMadeByEnum type in Enum.GetValues(typeof(RVMadeByEnum)))
                        {
                            byte index = (byte)type;
                            string name = NameMapping.RVMadeByEnumNameArray[index];
                            if (type != RVMadeByEnum.Other)
                            {
                                if (type == Model.MadeBy)
                                {
                                    <option value="@index" selected="selected">@name</option>
                                }
                                else
                                {
                                    <option value="@index">@name</option>
                                }
                            }
                        }
                        byte RVMadeByOtherIndex = (byte)RVMadeByEnum.Other;
                        string RVMadeByOtherName = NameMapping.RVTypeEnumNameArray[RVMadeByOtherIndex];
                        if (RVMadeByEnum.Other == Model.MadeBy)
                        {
                            <option value="@RVMadeByOtherIndex" selected="selected">@RVMadeByOtherName</option>
                        }
                        else
                        {
                            <option value="@RVMadeByOtherIndex">@RVMadeByOtherName</option>
                        }
                    }
                    </select>
                    <span id="msg_made_by" style="display: none;"></span>
                    <div id="J_RVMadeWrap" class="made-wrap" style="display: none;">
                        <label for="made" class="label" style="width: 50px; margin-left: 30px; padding-right: 0;">Make</label>
                        <input id="made" class="input-text" type="text" name="made"  data-msgbox="#msg_made"/>
                    </div>
                </div>
                <div class="row clearfix">
                    <label class="label"></label>
                    @{
                        bool isCheck = Model.IsAllowedHandleBooking;
                        if(isCheck)
                        {
                            <label for="rv_agree" class="agree">
                                <input id="rv_agree" class="chk" type="checkbox" name="agree" value="true" checked="checked"/>
                                <input type="hidden" name="agree" value="false"/>
                                <span>I wish HyRental to handle online booking for your (Leave it unchecked if you only want your list to show on Hyrental for free)</span>
                            </label>
                        }
                        else
                        {
                            <label for="rv_agree" class="agree">
                                <input id="rv_agree" class="chk" type="checkbox" name="agree" value="true"/>
                                <input type="hidden" name="agree" value="false"/>
                                <span>I wish HyRental to handle online booking for your (Leave it unchecked if you only want your list to show on Hyrental for free)</span>
                            </label>
                        }
                        
                    }
                </div>
                <div class="row clearfix">
                    <a id="J_Sumbit" href="javascript:;" class="btn btn-large submit">Save</a>
                </div>
            </div>
        </form>
    </div>
    <div class="layout-primary-right"></div>
</div>